using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class CategoryPriceExceptMap : EntityTypeConfiguration<CategoryPriceExcept>
    {
        public CategoryPriceExceptMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("CategoryPriceExcept");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PlistId).HasColumnName("PlistId");
            this.Property(t => t.Percentage).HasColumnName("Percentage");
            this.Property(t => t.CategoryId).HasColumnName("CategoryId");

            // Relationships
            this.HasRequired(t => t.PriceLst)
                .WithMany(t => t.CategoryPriceExcepts)
                .HasForeignKey(d => d.PlistId);

        }
    }
}
